package za.org.meraka.cair.ontorepair;

//PROTEGE IMPORTS
import org.protege.editor.core.ui.util.ComponentFactory;
import org.protege.editor.owl.ui.clsdescriptioneditor.*;
import org.protege.editor.owl.ui.renderer.OWLModelManagerEntityRenderer;
import org.protege.editor.owl.ui.renderer.OWLObjectRenderer;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.*;
//import org.semanticweb.owlapi.inference.*;
import org.semanticweb.owlapi.reasoner.OWLReasoner;
import org.semanticweb.owlapi.util.SimpleIRIMapper;
import org.protege.editor.owl.model.classexpression.OWLExpressionParserException;
import org.protege.editor.owl.model.event.*;//OWLExpressionParserException;
import org.protege.editor.owl.ui.view.AbstractOWLViewComponent;

import uk.ac.manchester.cs.owlapi.modularity.ModuleType;
import uk.ac.manchester.cs.owlapi.modularity.SyntacticLocalityModuleExtractor;
import za.org.meraka.cair.ontorepair.JustificationList;

//JAVA IMPORTS

import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.event.ListSelectionEvent;

//import java.net.IRI;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
import java.util.Collections;

public class TestPluginView extends AbstractOWLViewComponent{
    /**
	 * 
	 */	
	private static final long serialVersionUID = 1L;
    private OWLModelManagerEntityRenderer entityRenderer;
    private OWLObjectRenderer objectRenderer;	
    private OWLOntologyManager ontologyManager;
    private OWLOntology originalOntology, logicalOntology;
    private ExpressionEditor<OWLClassAxiom> owlClassExpressionManager;        
	private Set<OWLAxiom> listOfAxioms;	
	private OWLAxiom mainAxiom;	
	private OWLReasoner reasoner;
	private Set<Set<OWLAxiom>> naiveURepairs; 
	private JustificationGenerator jGen;
	private OWLOntology mdule;
	private ModuleExtractor m;
	private RepairGenerator rep;
	private Signature s;
	private int totalNaive;
	private SyntacticLocalityModuleExtractor synt;
	private Set<OWLAxiom> naiveModule;
	
    private JComponent resultPanel,editorPanel;
    private JButton checkButton, checkButton1, checkButton2, checkButton3, checkButton4, checkButton5, checkButton6, checkButton7, clearButton,clearAllButton;                   
    private JList axiomList;;        
    private DefaultListModel listModel;    
    private JustificationList resultsList;    
    private Set<Justification> justifs, repairsComputed, naiveRepairsComputed;
    private Set<FullJustification> fullJs;
    private Set<AxiomDescTuple> axiomDesc;
    private Set<OWLClassExpression> descs;

    private Set<Set<OWLAxiom>> normalJust;
    private AxiomNumberChecker numberChecker;
    private boolean done, allJComputed,allRJComputed, computeSelected,rootRepairsComputed, naiveRepairsDone = false;    
    private String tmpStr;
    private int axiomCnt;
    private IRI logicalIRI;
	static final String logicalOntIRI = "http://www.test.org/ontologies/logicalOnt.owl";
	static final String logicalPhysIRI = "file:/tmp/logical.owl";	
	static final String tmpOntIRI = "http://www.test.org/ontologies/tmpOnt.owl";
	static final String tmpPhysIRI = "file:/tmp/tmp.owl";
                
    public void initialiseOWLView() throws Exception {
    	
    	setLayout(new GridLayout(1,2));    	
    	UIManager.getDefaults().getColor(Color.gray);
    	axiomCnt = 0;        
    	final OWLExpressionChecker<OWLClassAxiom> checker = getOWLModelManager().getOWLExpressionCheckerFactory().getClassAxiomChecker();    	
		owlClassExpressionManager  = new ExpressionEditor<OWLClassAxiom>(getOWLEditorKit(), checker);		

		entityRenderer = getOWLModelManager().getOWLEntityRenderer();
		objectRenderer = getOWLModelManager().getOWLObjectRenderer();   		

        editorPanel = createEditor();
        resultPanel = createResult();        
        originalOntology = getOWLModelManager().getActiveOntology();
        justifs = repairsComputed = naiveRepairsComputed = new HashSet<Justification>();
        naiveURepairs = new HashSet<Set<OWLAxiom>>();
        fullJs = new HashSet<FullJustification>();
        axiomDesc = new HashSet<AxiomDescTuple>();
        descs = new HashSet<OWLClassExpression>();
        m = new ModuleExtractor();
        rep = new RepairGenerator();        
        listOfAxioms = naiveModule = new HashSet<OWLAxiom>();
        normalJust = new HashSet<Set<OWLAxiom>>();
        totalNaive = 0;
        
        add(resultPanel);	
		add(editorPanel);								
    }
                                               
    public JComponent createResult(){    	 
    	JComponent resultsPanel = new JPanel(new BorderLayout(10, 10));
        resultsPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(
                Color.LIGHT_GRAY), "Results"), BorderFactory.createEmptyBorder(3, 3, 3, 3)));
        resultsList = new JustificationList(getOWLEditorKit());       
        resultsPanel.add(ComponentFactory.createScrollPane(resultsList));
        return resultsPanel;
    }
    
    public JComponent createEditor(){
    	JPanel editorPanelFinal = new JPanel();
    	editorPanelFinal.setLayout(new BoxLayout(editorPanelFinal, BoxLayout.PAGE_AXIS));
    	
    	JPanel editorPanel = new JPanel();

    	editorPanel.setLayout(new BorderLayout());
    	JPanel editorPanel2 = new JPanel();
    	editorPanel2.setLayout(new BoxLayout(editorPanel2, BoxLayout.PAGE_AXIS));
    	listModel = new DefaultListModel();
    	axiomList = new JList(listModel); 
    	axiomList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    	axiomList.getSelectionModel().addListSelectionListener(new AxiomSelectionHandler(){
    		public void valueChanged(ListSelectionEvent e) {
    			ListSelectionModel lsm = axiomList.getSelectionModel();
    			
    			if (!lsm.isSelectionEmpty()) {    	            	        
    	        	try{displayJustification(getAJPair(axiomList.getSelectedValue()));}
    	        	catch(OWLException exc){}    	        	
    	        }
    		}
    	});    	    	  
    	
    	JScrollPane pane = new JScrollPane(axiomList);    	    
    	    	    	
        owlClassExpressionManager.setPreferredSize(new Dimension(200, 50));                   
                                                
        editorPanel.add(pane, BorderLayout.CENTER);                        
        editorPanel2.add(ComponentFactory.createScrollPane(owlClassExpressionManager));
        
        JPanel buttonHolder = new JPanel(new GridLayout(1,2));
        JPanel buttonHolder2 = new JPanel(new GridLayout(1,2));
        JPanel buttonHolder3 = new JPanel(new GridLayout(1,4));
        JPanel buttonHolder4 = new JPanel(new GridLayout(1,2));
                        
        clearButton = new JButton(new AbstractAction("Clear selected") {
        	/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){
				allRJComputed = false;
				rootRepairsComputed = false;
				naiveRepairsDone = false;
				Object[] a = axiomList.getSelectedValues();				
				
				removeAxioms(a);
				
				//try{
				for (int i = 0; i < a.length;i++){					
					//OWLAxiom axiom = (OWLAxiom)OWLClassExpressionManager.getExpressionChecker().createObject(a[i].toString());				
					listModel.removeElement(a[i]);
				}	
				//}
				//catch(OWLException excep){}
				
			}
        });

        clearAllButton = new JButton(new AbstractAction("Clear All") {
        	/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){
				axiomList.removeAll();
				listModel.removeAllElements();
				listOfAxioms.clear();				
			}
        });
        
        checkButton1 = new JButton(new AbstractAction("Add to list [Return]") {       	
            /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){try{allRJComputed = false;allJComputed = false;rootRepairsComputed = false;addToList();}catch(OWLExpressionParserException parser){System.out.println(parser.toString());}catch(OWLException parser){System.out.println(parser.toString());}}
        });
        
        //Keyboard1
        owlClassExpressionManager.getInputMap().put(KeyStroke.getKeyStroke("ENTER"),
        "doSomething");
        owlClassExpressionManager.getActionMap().put("doSomething",
         checkButton1.getAction());
        
        checkButton = new JButton(new AbstractAction("Root Justifications") {
            /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){
            	try{
            	axiomList.clearSelection();    
            	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	
            	computeRootJustifications();
            	    
		    	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		    	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            	}
            	catch (OWLException t){            		
            	}
            }
        });                
              
        checkButton2 = new JButton(new AbstractAction("Selected Justifications") {
            /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){
            	try{
            	computeSelected = true;            	    	
            	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	
            	for (Object o: axiomList.getSelectedValues()){
            		computeNormalJ(getAJPair(o));
            	}
            	            	            	    	
		    	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		    	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            	}
            	catch (OWLException t){}
            }
        });
        
        checkButton4 = new JButton(new AbstractAction("All Justifications") {
            /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){
            	try{
            	axiomList.clearSelection();            	    	
            	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	
            	computeNormalJustifications();
            	            	    
		    	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		    	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            	}
            	catch (OWLException t){}
            }
        });
        
        checkButton5 = new JButton(new AbstractAction("Naive Root J") {
            /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){
            	try{
            	axiomList.clearSelection();    	
            	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	
            	computeNaiveRootJustifications();
            	    
		    	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		    	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            	}
            	catch (OWLException t){}
            }
        });
        
        checkButton6 = new JButton(new AbstractAction("Naive Repairs") {
            /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){
            	try{
            	axiomList.clearSelection();    	
            	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	
            	computeNaiveRepair();
            	    	
		    	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		    	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            	}
            	catch (OWLException t){}
            }
        });
        
        checkButton7 = new JButton(new AbstractAction("Root Repairs") {
            /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e){
            	try{
            	axiomList.clearSelection();    	
            	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            	
            	computeRootRepair();
            	    	
		    	owlClassExpressionManager.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		    	axiomList.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            	}
            	catch (OWLException t){}
            }
        });  
        
        //Keyboard2
        owlClassExpressionManager.getInputMap().put(KeyStroke.getKeyStroke("F5"),
        "doSomethingElse");
        owlClassExpressionManager.getActionMap().put("doSomethingElse",
         checkButton.getAction());        
        
        //Keyboard3
        axiomList.getInputMap().put(KeyStroke.getKeyStroke("F5"),
        "doSomethingElse");
        axiomList.getActionMap().put("doSomethingElse",
         checkButton.getAction());               
        
        checkButton3 = new JButton(new AbstractAction("Clear text") {
            /**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e) {clearAxiom();}
        });
                
        //Keyboard4             
        pane.setEnabled(true);
        axiomList.getInputMap().put(KeyStroke.getKeyStroke("DELETE"),
        "doSomethingElse5");
        axiomList.getActionMap().put("doSomethingElse5",
         clearButton.getAction());        
        
        buttonHolder2.add(clearButton);
        buttonHolder2.add(clearAllButton);
        
        buttonHolder.add(checkButton1);
        buttonHolder.add(checkButton3);
        
        buttonHolder3.add(checkButton2);
        buttonHolder3.add(checkButton4);
        //buttonHolder3.add(checkButton5);
        buttonHolder3.add(checkButton);
        
        buttonHolder4.add(checkButton6);
        buttonHolder4.add(checkButton7);
        
        editorPanel.add(buttonHolder2, BorderLayout.PAGE_END);
        editorPanel2.add(buttonHolder);
        editorPanel2.add(buttonHolder3);
        editorPanel2.add(buttonHolder4);
        
        editorPanel2.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(
                Color.LIGHT_GRAY), "Enter Axiom"), BorderFactory.createEmptyBorder(3, 3, 3, 3)));               
        
        editorPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(
                Color.LIGHT_GRAY), "Unwanted Axioms"), BorderFactory.createEmptyBorder(3, 3, 3, 3)));               
                        
        editorPanelFinal.add(editorPanel);                
        editorPanelFinal.add(editorPanel2);
        return editorPanelFinal;
    }
                            
    private void addToList() throws OWLException { 
    	if (owlClassExpressionManager.getText().equals("")){		
    	}
    	else{
    		allRJComputed = false;
    		naiveRepairsDone = false;
    		OWLAxiom axiom = (OWLAxiom)owlClassExpressionManager.getExpressionChecker().createObject(owlClassExpressionManager.getText());    			    		
    			
    		try{
    			if (!listOfAxioms.contains(axiom)){
    				tmpStr = "";
    				axiomCnt++;    	
    				tmpStr += objectRenderer.render(axiom);    	
    				listModel.addElement(tmpStr);    		    		
    				listOfAxioms.add(axiom);
    				clearAxiom();
    			}
    		}	
    		catch (NullPointerException e){}
    	}
    }
          
    private void removeAxioms(Object[] a){
    	Set<OWLAxiom> toRemove = new HashSet<OWLAxiom>();
    	String t = "";
    	getOWLModelManager().getOWLDataFactory();
    	for (int j = 0; j < a.length;j++){    		
    		for (OWLAxiom ax: listOfAxioms){
    			t = objectRenderer.render(ax);
    			if (t.equals(a[j].toString())){
    				toRemove.add(ax);
    			}
    		}
    	}
    	    	
    	listOfAxioms.removeAll(toRemove);    	    		
    }
                
    private void clearAxiom(){owlClassExpressionManager.setText("");}    
        
    private OWLAxiom getAJPair(Object o) throws OWLException{
    	OWLAxiom ax = (OWLAxiom)owlClassExpressionManager.getExpressionChecker().createObject(o.toString());
    	for (OWLAxiom a: listOfAxioms){
    		if (a.toString().equals(ax.toString()))
    			return a;
    	}    	
    	return null;	
    }
                                      
    private void displayRootJustifications(Set<Justification> j) throws OWLException{
    	resultsList.displayRootJustifications(j);			    										    					    					    					    					    					
    }
    
    private void displayRootRepairSets(Set<Justification> j) throws OWLException{
    	resultsList.displayRootRepairSets(j);			    										    					    					    					    					    					
    }
    
    private void displayNaiveRepairSets(Set<Justification> j) throws OWLException{
    	resultsList.displayNaiveRepairSets(j);			    										    					    					    					    					    					
    }
               
    private OWLAxiom subClassAxiom() throws OWLException{
    	OWLOntologyManager ontManager = OWLManager.createOWLOntologyManager();
		OWLReasoner reasoner = getOWLModelManager().getReasoner();//getOWLReasonerManager().createReasoner(ontManager);
    	if (mainAxiom.getAxiomType().equals(AxiomType.SUBCLASS_OF)){
    		OWLSubClassOfAxiom subCl = (OWLSubClassOfAxiom)mainAxiom;
    		OWLClassExpression rhs = subCl.getSuperClass();
    		OWLClassExpression lhs = subCl.getSubClass();
    		//reasoner.loadOntologies(Collections.singleton(originalOntology));
    		//if (reasoner.isEquivalentClass(rhs, getOWLModelManager().getOWLDataFactory().getOWLNothing())){
    			//mainAxiom = getOWLModelManager().getOWLDataFactory().getOWLSubClassAxiom(lhs, getOWLModelManager().getOWLDataFactory().getOWLNothing());    			
    		//}    					
    	}
    	return mainAxiom;
    }       
    
    private void displayJustification(OWLAxiom a) throws OWLException{
    	for (FullJustification fullJ: fullJs){
    		if (fullJ.entailment.toString().equals(a.toString())){
    			resultsList.displayJustifications(fullJ);
    		}
    	}		
    }
                
    private void populateAxiomDescPairs(Set<OWLAxiom> axiomArr) throws OWLException{
    	//reasoner.clearOntologies();
    	//reasoner.loadOntologies(Collections.singleton(logicalOntology));
    	
    	AxiomParser parser = new AxiomParser(getOWLModelManager());
    	for (OWLAxiom a: axiomArr){    		    		 
    		OWLClassExpression d = parser.getOWLClassExpression(a);
    		if (!reasoner.isSatisfiable(d)){
    			axiomDesc.add(new AxiomDescTuple(a, d));
    			descs.add(d);
    		}
    	}
    }
        
    private void computeNormalJustifications() throws OWLException{
    	System.out.println("Compute Normal Justifications All");
    	System.out.println("---------------------------------");
    	System.out.println();
    	fullJs = new HashSet<FullJustification>();        	        	
    	//if (isShowing()){    	        			    		    		
    		if (getOWLModelManager().getReasoner().isConsistent()) {
    			if (listOfAxioms.size() > 0){    				    				    				    					    			        				    				   		
    				/*******************************************************************/
    					System.gc();
    					long start = System.currentTimeMillis();
    					originalOntology = getOWLModelManager().getActiveOntology();
    				    				        				   				    				    				    				    				    			
    					calculateLogicalOntology();    				
    				
    					AxiomParser parser = new AxiomParser(getOWLModelManager());
    					Set<OWLClassExpression> descs = new HashSet<OWLClassExpression>();
    					Set<OWLEntity> sig = new HashSet<OWLEntity>();
    					    					
    					for (OWLAxiom a: listOfAxioms){  
    						OWLSubClassOfAxiom subClsAx;
    						Set<OWLEntity> signLHS = new HashSet<OWLEntity>();
    						Set<OWLEntity> signRHS = new HashSet<OWLEntity>();
    						Set<OWLEntity> signTotal = new HashSet<OWLEntity>();
							if (a.isOfType(AxiomType.SUBCLASS_OF)){
								subClsAx = (OWLSubClassOfAxiom)a;
								signLHS = subClsAx.getSubClass().getSignature();
								System.out.println(signLHS.size());
								signRHS = subClsAx.getSuperClass().getSignature();
								System.out.println(signRHS.size());
								signTotal.addAll(signLHS);signTotal.addAll(signRHS);
								System.out.println(signTotal.size());
							}
							
							Signature s;
							s = new Signature(signRHS);
    						ModuleExtractor m = new ModuleExtractor();
    						//JustificationGenerator gen = new JustificationGenerator(getOWLModelManager(), s, logicalOntology);
    						OWLOntology o;
    						System.out.println("ontology axioms (b): " + logicalOntology.getAxiomCount());
    						o = m.extractModule(logicalOntology, logicalOntology.getOWLOntologyManager(), s);
    						System.out.println("ontology axioms (a): " + logicalOntology.getAxiomCount());
    						//System.out.println("ontology axioms: " + originalOntology.getAxiomCount());
    						System.out.println("LHS module axioms: " + o.getAxiomCount());
    						
    						s = new Signature(signRHS);
    						o = m.extractModule(logicalOntology, logicalOntology.getOWLOntologyManager(), s);
    						//System.out.println("ontology axioms: " + originalOntology.getAxiomCount());
    						System.out.println("RHS module axioms: " + o.getAxiomCount());
    						
    						s = new Signature(signTotal);
    						o = m.extractModule(logicalOntology, logicalOntology.getOWLOntologyManager(), s);
    						//System.out.println("ontology axioms: " + originalOntology.getAxiomCount());
    						System.out.println("Total module axioms: " + o.getAxiomCount());
    						 				
    						/*if ((o.getAxiomCount()+o2.getAxiomCount()) == o3.getAxiomCount()){
    							System.out.println("Valid");
    						}
    						else{
    							System.out.println("Invalid");
    						}*/
    						
    						//mainAxiom = a;
    						//mainAxiom = subClassAxiom();    						
    						//descs.add(parser.getOWLClassExpression(mainAxiom));
    						//descs.add(parser.getOWLClassExpression(a));
    					}
    					
    					/*Set<Set<OWLAxiom>> totalJs = new HashSet<Set<OWLAxiom>>();
    					
    					for (OWLClassExpression d: descs){    						
    						Signature s = new Signature(d.getSignature());
    						ModuleExtractor m = new ModuleExtractor();
    						JustificationGenerator gen = new JustificationGenerator(getOWLModelManager(), s, logicalOntology);
    						OWLOntology o = m.extractModule(logicalOntology, logicalOntology.getOWLOntologyManager(), s);
    						System.out.println("ontology axioms: " + originalOntology.getAxiomCount());
    						System.out.println("module axioms: " + o.getAxiomCount());
    						normalJust = gen.getJ(d, o);
    						justifs = new HashSet<Justification>();
    						for (Set<OWLAxiom> j: normalJust){    							
    							justifs.add(new Justification(getOWLModelManager(), mainAxiom, j));
    							totalJs.add(j);
    						}
    						     						
    						fullJs.add(new FullJustification(getOWLModelManager(), mainAxiom, justifs));    					
    						justifs = new HashSet<Justification>();  
    					}
    				        					    					    					
    					/*int satCount1 = 0;
    					int satCount2 = 0;
    					Set<Set<OWLAxiom>> totalJs = new HashSet<Set<OWLAxiom>>();
    					for (OWLAxiom a: listOfAxioms){    						
    						OWLClassExpression d = parser.getOWLClassExpression(a);
    						Signature s = new Signature(d.getSignature());
    						SyntacticLocalityModuleExtractor syn = new SyntacticLocalityModuleExtractor(ontologyManager, logicalOntology, ModuleType.STAR);
    						Set<OWLAxiom> module1 = syn.extract(s.elements);
    					
    						///////////////////////////////////////////////////////////////
    						OWLOntology tempOntology;
    						OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();    							
    						IRI ontologyIRI3 = IRI.create("http://www.meraka.org.za/ontologies/main5.owl");
    						IRI physicalIRI3 = IRI.create("file:/tmp/main5.owl");
    						SimpleIRIMapper mapper3 = new SimpleIRIMapper(ontologyIRI3, physicalIRI3);
    						manager2.addIRIMapper(mapper3);    					    
    						tempOntology = manager2.createOntology(ontologyIRI3);    				      	     	
    						manager2.addAxioms(tempOntology, module1);
    						/////////////////////////////////////////////////////////////////
    						
    						System.out.println("module1 axioms: " + tempOntology.getAxiomCount());
    						
    						for (OWLAxiom axio: tempOntology.getAxioms()){
    							System.out.println(objectRenderer.render(axio));
    						}
    						
    						/*ModuleExtractor m = new ModuleExtractor();
    						OWLOntology module = m.extractModule(logicalOntology, ontologyManager, s);
    						System.out.println("module axioms: " + module.getAxiomCount());*/
    						
    						/*JustificationGenerator gen = new JustificationGenerator(getOWLModelManager(), s, tempOntology);    				    					
    						normalJust = gen.getJ(d, tempOntology);
    						System.out.println("Number of duplicate justifications computed: " + gen.duplicates);
    						System.out.println("Time wasted computing duplicate justifications: " + gen.wastedTime + "ms");
    						//satCount1+=gen.bruteForceSatisfiabilityCount;
    						//satCount2+=gen.cleverSatisfiabilityCount;
    						
    						justifs = new HashSet<Justification>();
    						for (Set<OWLAxiom> j: normalJust){    							
    							justifs.add(new Justification(getOWLModelManager(), a, j));
    							totalJs.add(j);
    						}
    						     						
    						fullJs.add(new FullJustification(getOWLModelManager(), a, justifs));    					
    						justifs = new HashSet<Justification>();      						
    					}       					
    					
    					totalJs = new HashSet<Set<OWLAxiom>>();
    					
    					long end = System.currentTimeMillis();
    					
    					allJComputed = true;
    					JOptionPane.showMessageDialog(this,"Time taken: " + (end - start) + "ms","Task Completed",JOptionPane.INFORMATION_MESSAGE);	
    					/*******************************************************************/
    					/*totalJs = new HashSet<Set<OWLAxiom>>();    					
    					long end = System.currentTimeMillis();    					
    					allJComputed = true;
    					JOptionPane.showMessageDialog(this,"Time taken: " + (end - start) + "ms","Task Completed",JOptionPane.INFORMATION_MESSAGE);*/	
    			}
    			else{
    				JOptionPane.showMessageDialog(this,"Unwanted Axiom list is empty.","Please add unwanted axiom(s)",JOptionPane.WARNING_MESSAGE);    			
    			}
    		}
    		else{
    			axiomList.clearSelection();
    			JOptionPane.showMessageDialog(this,"Please select a reasoner from the Reasoner menu","No reasoner selected",JOptionPane.WARNING_MESSAGE);
    		}    		
    	//}              	
    	//else{}
    }
    
    private void computeRootJustifications() throws OWLException{
    	if (!allRJComputed || justifs.size() == 0){      			    		    		
    		if (isShowing()){    	        			    		    		
    			if (getOWLModelManager().getReasoner().isConsistent()) {
    				if (listOfAxioms.size() > 0){    				    				    				    					    			        				    				   		
    				/*******************************************************************/    				    				
    				originalOntology = getOWLModelManager().getActiveOntology();    				    				        				    				    				    				    				    				    	
    				calculateLogicalOntology(); 
    				reasoner = getOWLModelManager().getReasoner();
    				//reasoner = getOWLModelManager().getOWLReasonerManager().createReasoner(ontologyManager);
    				axiomDesc = new HashSet<AxiomDescTuple>();
    	    		populateAxiomDescPairs(listOfAxioms);    	
    				Set<OWLEntity> sig = new HashSet<OWLEntity>();
    					
    				for (AxiomDescTuple a: axiomDesc)
    					sig.addAll(a.axiom.getSignature());    						    					    				    					    					    				        		
    				
    				Signature s = new Signature(sig);
    				SyntacticLocalityModuleExtractor syn = new SyntacticLocalityModuleExtractor(ontologyManager, logicalOntology, ModuleType.STAR);
					Set<OWLAxiom> module1 = syn.extract(s.elements);
					
					///////////////////////////////////////////////////////////////
					OWLOntology module;
					OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();    							
					IRI ontologyIRI3 = IRI.create("http://www.meraka.org.za/ontologies/main5.owl");
					IRI physicalIRI3 = IRI.create("file:/tmp/main5.owl");
					SimpleIRIMapper mapper3 = new SimpleIRIMapper(ontologyIRI3, physicalIRI3);
					manager2.addIRIMapper(mapper3);    					    
					module = manager2.createOntology(ontologyIRI3);    				      	     	
					manager2.addAxioms(module, module1);
					/////////////////////////////////////////////////////////////////
					
    				JustificationGenerator gen = new JustificationGenerator(getOWLModelManager(), axiomDesc, s, originalOntology);
    				StopWatch s1 = new StopWatch();	
					System.gc();
    				s1.start();
    				gen.getRJ(module);    				    				
    				allRJComputed = true;
    				justifs = gen.getRootJustifications();
    				s1.stop();
    				displayRootJustifications(justifs);
    				
    				//System.out.println("brute force satisfiability tests: " + gen.bruteForceSatisfiabilityCount);
					//System.out.println("clever satisfiability tests: " + gen.cleverSatisfiabilityCount);
       				JOptionPane.showMessageDialog(this,"Time taken: " + s1.getElapsedTime() + "ms","Task Completed",JOptionPane.INFORMATION_MESSAGE);
   					/*******************************************************************/    					    				    			    				    				    				
    				}
    				else{
    					JOptionPane.showMessageDialog(this,"Unwanted Axiom list is empty.","Please add unwanted axiom(s)",JOptionPane.WARNING_MESSAGE);    			
    				}
    			}
    			else{
    				axiomList.clearSelection();
    				JOptionPane.showMessageDialog(this,"Please select a reasoner from the Reasoner menu","No reasoner selected",JOptionPane.WARNING_MESSAGE);
    			}    		
    		}              	
    		else{}
    	}
    	else{
    		displayRootJustifications(justifs);
    	}
    }
    
    private void computeRootRepair() throws OWLException{
    	System.out.println("Root:");
    	System.out.println("------");
    	System.out.println();
    	if (isShowing()){
    		//if (!rootRepairsComputed){
    			if (getOWLModelManager().getReasoner().isConsistent()) {
    				if (listOfAxioms.size() > 0){    				    				    				    					    			        				    				   		
    				/*******************************************************************/    				
    				originalOntology = getOWLModelManager().getActiveOntology();    				    				        				    				    				    				    				    				    	
    				calculateLogicalOntology();    	
    				reasoner = getOWLModelManager().getReasoner();
    				//reasoner = getOWLModelManager().getOWLReasonerManager().createReasoner(ontologyManager);
    				axiomDesc = new HashSet<AxiomDescTuple>();
    		    	populateAxiomDescPairs(listOfAxioms);  
    		    	    		    	
    				Set<OWLEntity> sig = new HashSet<OWLEntity>();

    				for (AxiomDescTuple a: axiomDesc)
    					sig.addAll(a.axiom.getSignature());    				    						    					    				    					    		    				        	

    				s = new Signature(sig);
    				
    				SyntacticLocalityModuleExtractor syn = new SyntacticLocalityModuleExtractor(ontologyManager, logicalOntology, ModuleType.STAR);
					Set<OWLAxiom> module1 = syn.extract(s.elements);
					
					///////////////////////////////////////////////////////////////
					OWLOntology tempOntology;
					OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();    							
					IRI ontologyIRI3 = IRI.create("http://www.meraka.org.za/ontologies/main5.owl");
					IRI physicalIRI3 = IRI.create("file:/tmp/main5.owl");
					SimpleIRIMapper mapper3 = new SimpleIRIMapper(ontologyIRI3, physicalIRI3);
					manager2.addIRIMapper(mapper3);    					    
					tempOntology = manager2.createOntology(ontologyIRI3);    				      	     	
					manager2.addAxioms(tempOntology, module1);
					/////////////////////////////////////////////////////////////////
					
					System.out.println("module1 axioms: " + tempOntology.getAxiomCount());
    				
    				//mdule = m.extractModule(logicalOntology, ontologyManager, s);
    				JustificationGenerator gen = new JustificationGenerator(getOWLModelManager(), axiomDesc, s, originalOntology);
    				
    				StopWatch s = new StopWatch();
    				System.gc();
    				s.start();
    				gen.getRJ(tempOntology);    				    			
    				repairsComputed = rep.getRepairSets(gen.getRootJustifications());
    				s.stop();
    				rootRepairsComputed = true;
    				displayRootRepairSets(repairsComputed);
    				System.out.println("Total Satisfiability Tests: " + gen.totalRoot);
    				System.out.println("Number of U-Repairs: " + repairsComputed.size());
    				System.out.println();
    				JOptionPane.showMessageDialog(this,"Time taken: " + s.getElapsedTime() + "ms","Task Completed",JOptionPane.INFORMATION_MESSAGE);
    				/*******************************************************************/    					    				    			    				    				    				
    				}
    				else{
    					JOptionPane.showMessageDialog(this,"Unwanted Axiom list is empty.","Please add unwanted axiom(s)",JOptionPane.WARNING_MESSAGE);    			
    				}
    			}
    			else{
    				axiomList.clearSelection();
    				JOptionPane.showMessageDialog(this,"Please select a reasoner from the Reasoner menu","No reasoner selected",JOptionPane.WARNING_MESSAGE);
    			}
    		}
    		/*else{
    			displayRootRepairSets(repairsComputed);
        	}*/    	              
    	else{}    	    	
    }
            
    private void computeNaiveRootJustifications() throws OWLException{
    	fullJs = new HashSet<FullJustification>();        	        	
    	if (isShowing()){    	        			    		    		
    		if (getOWLModelManager().getReasoner().isConsistent()) {
    			if (listOfAxioms.size() > 0){    				    				    				    					    			        				    				   		
    				/*******************************************************************/
    				originalOntology = getOWLModelManager().getActiveOntology();
    				    				        				   				    				    				    				    				    			
    					calculateLogicalOntology();    				
    				
    					AxiomParser parser = new AxiomParser(getOWLModelManager());
    					Set<OWLClassExpression> descs = new HashSet<OWLClassExpression>();
    					Set<OWLEntity> sig = new HashSet<OWLEntity>();
    					
    					
    					for (OWLAxiom a: listOfAxioms){    						
    						mainAxiom = a;
    						mainAxiom = subClassAxiom();    						
    						descs.add(parser.getOWLClassExpression(mainAxiom));
    					}    					    					    				        		
    				    
    					long start = System.currentTimeMillis();
    					    					
    					int satCount1 = 0;
    					int satCount2 = 0;
    					for (OWLAxiom a: listOfAxioms){    						
    						OWLClassExpression d = parser.getOWLClassExpression(a);
    						Signature s = new Signature(d.getSignature());
    						ModuleExtractor m = new ModuleExtractor();
    						OWLOntology module = m.extractModule(logicalOntology, ontologyManager, s);
    				    				
    						JustificationGenerator gen = new JustificationGenerator(getOWLModelManager(),s, originalOntology);    				
    					
    						normalJust = gen.getJ(d, module);
    						
    						//satCount1+=gen.bruteForceSatisfiabilityCount;
    						//satCount2+=gen.cleverSatisfiabilityCount;
    						
    						for (Set<OWLAxiom> j: normalJust)    							
    							justifs.add(new Justification(getOWLModelManager(), a, j));
    						    						     					
    						fullJs.add(new FullJustification(getOWLModelManager(), a, justifs));    					
    						justifs = new HashSet<Justification>();    				    					   					
    					}
    					
    					JustificationGenerator gen2 = new JustificationGenerator();
    					
    					Set<Justification> ju = new HashSet<Justification>();
    					for (FullJustification fullJ: fullJs){
    						ju.addAll(fullJ.justifications);
    					}
    					    					
						displayRootJustifications(gen2.getRoots(ju));
    					
						fullJs = new HashSet<FullJustification>();
						
    					long end = System.currentTimeMillis();
    					
    					//allJComputed = true;
    					JOptionPane.showMessageDialog(this,"Time taken: " + (end - start) + "ms","Task Completed",JOptionPane.INFORMATION_MESSAGE);	
    					/*******************************************************************/    					    				    			    				    				
    				
    					System.out.println("brute force satisfiability tests: " + satCount1);
    					System.out.println("clever satisfiability tests: " + satCount2);
    			}
    			else{
    				JOptionPane.showMessageDialog(this,"Unwanted Axiom list is empty.","Please add unwanted axiom(s)",JOptionPane.WARNING_MESSAGE);    			
    			}
    		}
    		else{
    			axiomList.clearSelection();
    			JOptionPane.showMessageDialog(this,"Please select a reasoner from the Reasoner menu","No reasoner selected",JOptionPane.WARNING_MESSAGE);
    		}    		
    	}              	
    	else{}
    }
    
    private OWLClassExpression chooseDesc(Set<OWLClassExpression> descs, OWLOntology ontology) throws OWLException{    	
    	for (OWLClassExpression d: descs){
    		if (d != null)
    			return d;
    	}    	
    	return null;
    }
    
    private Set<OWLClassExpression> checkList(OWLOntology ontology, Set<OWLClassExpression> descs) throws OWLException{
    	Set<OWLClassExpression> result = new HashSet<OWLClassExpression>();    	
    	//reasoner.clearOntologies();
    	//reasoner.loadOntologies(Collections.singleton(ontology));
    	for (OWLClassExpression d: descs){
    		if (!reasoner.isSatisfiable(d))
    			result.add(d);    		
    	}
    	return result;
    }
    
    private Set<OntologyDescsPair> getNewCandidateOntologies(Set<Set<OWLAxiom>> ontologies, Set<OWLClassExpression> descs) throws OWLException{
    	Set<OntologyDescsPair> result = new HashSet<OntologyDescsPair>();
    	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    	for (Set<OWLAxiom> axioms: ontologies){
    		OWLOntology ont = manager.createOntology(axioms);
    		//reasoner.clearOntologies();
        	//reasoner.loadOntologies(Collections.singleton(ont));        	
        	Set<OWLClassExpression> currentDescs = new HashSet<OWLClassExpression>();
    		for (OWLClassExpression d: descs){
    			if (!reasoner.isSatisfiable(d)){
    				currentDescs.add(d);
    			}
    		}
    		if (currentDescs.size() == 0){
    			naiveURepairs.add(axioms);
    		}
    		else{
    			result.add(new OntologyDescsPair(ont, currentDescs));
    		}    			
    	}
    	
    	return result;
    }
        
    private OWLOntology createOntology(Set<OWLAxiom> axioms) throws OWLException{
    	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
		
		/*IRI ontologyIRI3 = IRI.create("http://www.meraka.org.za/ontologies/main3.owl");
		IRI physicalIRI3 = IRI.create("file:/tmp/main3.owl");
		SimpleIRIMapper mapper3 = new SimpleIRIMapper(ontologyIRI3, physicalIRI3);
		manager2.addIRIMapper(mapper3);*/
	    
		return manager.createOntology(axioms);
    }
    
    private Set<Set<OWLAxiom>> naiveRepair(OWLOntology ontology, Set<OWLClassExpression> descs) throws OWLException{    	
    	Set<Set<OWLAxiom>> allJ = new HashSet<Set<OWLAxiom>>();
    	/*****************************Choose unwanted axiom******************************/
    	OWLClassExpression desc = chooseDesc(descs, ontology);    	
    	/*****************************Module Extraction**********************************/
    	s = new Signature(desc.getSignature());
    	synt = new SyntacticLocalityModuleExtractor(ontologyManager, ontology, ModuleType.STAR);
		naiveModule = synt.extract(s.elements);
		
		///////////////////////////////////////////////////////////////
		OWLOntology tempOntology;
		OWLOntologyManager manager2 = OWLManager.createOWLOntologyManager();    							
		IRI ontologyIRI3 = IRI.create("http://www.meraka.org.za/ontologies/main5.owl");
		IRI physicalIRI3 = IRI.create("file:/tmp/main5.owl");
		SimpleIRIMapper mapper3 = new SimpleIRIMapper(ontologyIRI3, physicalIRI3);
		manager2.addIRIMapper(mapper3);    					    
		tempOntology = manager2.createOntology(ontologyIRI3);    				      	     	
		manager2.addAxioms(tempOntology, naiveModule);
		/////////////////////////////////////////////////////////////////
		
		System.out.println("module1 axioms: " + tempOntology.getAxiomCount());
		//mdule = m.extractModule(ontology, ontologyManager, s);
		/*****************************Compute Justifications*****************************/
		jGen = new JustificationGenerator(getOWLModelManager(),s,originalOntology);    				    					
		allJ = jGen.getJ(desc, tempOntology);
		totalNaive+=jGen.totalNaive;
		justifs = new HashSet<Justification>();
		for (Set<OWLAxiom> j: allJ)    							
			justifs.add(new Justification(getOWLModelManager(), null, j));
			
		/*****************************Compute U-diagnoses********************************/				
		naiveRepairsComputed = rep.getRepairSets(justifs);
		/*****************************Compute U-repairs**********************************/
		Set<Set<OWLAxiom>> candidateOntologies = new HashSet<Set<OWLAxiom>>();
		for (Justification repair: naiveRepairsComputed){
			List<OWLOntologyChange> adds = new ArrayList<OWLOntologyChange>();
   			List<OWLOntologyChange> rems = new ArrayList<OWLOntologyChange>();
			for (OWLAxiom a: repair.justification){
				rems.add(new RemoveAxiom(ontology, a));
				adds.add(new AddAxiom(ontology, a));
			}
			
			ontologyManager.applyChanges(rems);
			
			candidateOntologies.add(ontology.getAxioms());
			
			ontologyManager.applyChanges(adds);		
		}	
		/*******************************************************************************/
		Set<OWLClassExpression> newDescs = new HashSet<OWLClassExpression>();
		for (OWLClassExpression d: descs){
			if (!d.equals(desc))
				newDescs.add(d);
		}
		
		if (newDescs.size() == 0){
			naiveURepairs.addAll(candidateOntologies);
			return naiveURepairs;
		}
		else{
			Set<OntologyDescsPair> newCandidateOntologies = getNewCandidateOntologies(candidateOntologies, newDescs);
			if (candidateOntologies.size() == 0){
				return naiveURepairs;
			}
			else{												
				for (OntologyDescsPair o: newCandidateOntologies){					
						naiveRepair(o.ontology, o.descs);
				}					
				return naiveURepairs;
			}			
		}		
    }
    
    
    private void computeNaiveRepair() throws OWLException{ 
    	System.out.println("Naive:");
    	System.out.println("------");
    	System.out.println();
    	if (isShowing()){
    		if (!naiveRepairsDone){
    			if (getOWLModelManager().getReasoner().isConsistent()) {
    				if (listOfAxioms.size() > 0){    				    				    				    					    			        				    				   		
    				/*******************************************************************/

    				originalOntology = getOWLModelManager().getActiveOntology();
    				//numberChecker = new AxiomNumberChecker(originalOntology);
    				calculateLogicalOntology();  
    				reasoner = getOWLModelManager().getReasoner();
    				//reasoner = getOWLModelManager().getOWLReasonerManager().createReasoner(ontologyManager);
    		    	axiomDesc = new HashSet<AxiomDescTuple>();
    		    	populateAxiomDescPairs(listOfAxioms);    
    				StopWatch s = new StopWatch();
    				System.gc();
    		    	s.start();
    				Set<Set<OWLAxiom>> o = naiveRepair(logicalOntology, descs);
    				s.stop(); 				    
    				
    				System.out.println("Total Satisfiability tests: " + totalNaive);
    				
    				System.out.println("Number of U-Repairs: " + o.size());
    				UtilityClass<OWLAxiom> u = new UtilityClass<OWLAxiom>();
    				Set<Set<OWLAxiom>> ont = u.prune(o);    				
    				//System.out.println("Number of U-Repairs2: " + ont.size());    				
    				System.out.println();
    				
    				JOptionPane.showMessageDialog(this,"Time taken: " + s.getElapsedTime() + "ms","Task Completed",JOptionPane.INFORMATION_MESSAGE);
    				/*******************************************************************/    					    				    			    				    				    				
    				}
    				else{
    					JOptionPane.showMessageDialog(this,"Unwanted Axiom list is empty.","Please add unwanted axiom(s)",JOptionPane.WARNING_MESSAGE);    			
    				}
    			}
    			else{
    				axiomList.clearSelection();
    				JOptionPane.showMessageDialog(this,"Please select a reasoner from the Reasoner menu","No reasoner selected",JOptionPane.WARNING_MESSAGE);
    			}
    		}
    		else{
    			displayRootRepairSets(naiveRepairsComputed);
        	}
    	}              	
    	else{}    	   
    	
    }
    
    private void computeNormalJ(OWLAxiom axiom) throws OWLException{
    	System.out.println("Wrong");
    	//resultsList.setListData((new ArrayList()).toArray());
    	if (!allJComputed){    
    	if (isShowing()){    	        			    		    		
    		if (getOWLModelManager().getReasoner().isConsistent()) {    			    				    				    				    					    			       				    				    				   	
    			/*******************************************************************/
    			originalOntology = getOWLModelManager().getActiveOntology();
    			System.out.println("Ontology size: " + originalOntology.getAxiomCount());
    			
    			mainAxiom = axiom;
    			mainAxiom = subClassAxiom();
    				    				    				    				    			
    			calculateLogicalOntology();    				    				
    				    				
    			AxiomParser parser = new AxiomParser(getOWLModelManager());    				
    			OWLClassExpression desc = parser.getOWLClassExpression(mainAxiom);    				        			
    				
    			Signature s = new Signature(mainAxiom.getSignature());
    			ModuleExtractor m = new ModuleExtractor();
    			OWLOntology module = m.extractModule(logicalOntology, ontologyManager, s);   
    			
    			System.out.println("Module size: " + module.getAxiomCount());
    			System.out.println();
    				    				    			
    			JustificationGenerator gen = new JustificationGenerator(getOWLModelManager(), s, originalOntology);
    				
    			long start = System.currentTimeMillis();
    				
    			normalJust = gen.getJ(desc, module);
    			
    			long end = System.currentTimeMillis();
    			
    			justifs = new HashSet<Justification>();
    			for (Set<OWLAxiom> j: normalJust)
    				justifs.add(new Justification(getOWLModelManager(), axiom, j));
    			
    			fullJs.add(new FullJustification(getOWLModelManager(), axiom, justifs));
    			//pairs.add(new AxiomJPair(axiom, normalJust));
    			//displayJustification(axiom);
    			JOptionPane.showMessageDialog(this,"Time taken: " + (end - start) + "ms","Task Completed",JOptionPane.INFORMATION_MESSAGE);
    			/*******************************************************************/    				    				    				    				    				    				    				    				    	
    		}
    		else{
    			axiomList.clearSelection();
    			JOptionPane.showMessageDialog(this,"No reasoner selected.","Have you selected a reasoner?",JOptionPane.WARNING_MESSAGE);
    		}    	
    	}  
    	}
    	else{
    		displayJustification(axiom);
    	}
    }
        
    private void calculateLogicalOntology() {
		ontologyManager = OWLManager.createOWLOntologyManager();

		logicalIRI = IRI.create(logicalOntIRI);
		IRI physicalIRI = IRI.create(logicalPhysIRI);
		SimpleIRIMapper mapper = new SimpleIRIMapper(logicalIRI, physicalIRI);

		ontologyManager.addIRIMapper(mapper);

		try {
			logicalOntology = ontologyManager.createOntology(logicalIRI);
		} catch (OWLOntologyCreationException creationEx) {
			System.out.println("Failed to create ontology: "
					+ creationEx.toString());
			System.exit(1);
		}
		
		Set<OWLLogicalAxiom> axioms = originalOntology.getLogicalAxioms();
		
		ontologyManager.addAxioms(logicalOntology,
				axioms);						
	}
        
    public void disposeOWLView(){}
}
